package com.xulu.romance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xulu.romance.dao.QuestionDao;
import com.xulu.romance.pojo.Question;
import com.xulu.romance.service.QuestionService;
import com.xulu.romance.utils.PageUtils;
import com.xulu.romance.utils.Query;
import com.xulu.romance.vo.ArchiveQuestionVo;
import com.xulu.romance.vo.QuestionTopVo;
import com.xulu.romance.vo.QuestionVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author xiaoxulu
 * @Date 2024/1/13 22:01
 */

@Service
public class QuestionServiceImpl extends ServiceImpl<QuestionDao, Question> implements QuestionService {

    @Autowired
    private QuestionDao questionDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<Question> page = this.page(
                new Query<Question>().getPage(params),
                new QueryWrapper<Question>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer findQuestoinDetailCount() {
        return questionDao.findQuestoinDetailCount();
    }

    @Override
    public List<QuestionVo> findQuestoinDetail(Integer currentPage, Integer size) {
        return questionDao.findQuestoinDetail(currentPage, size);
    }

    @Override
    public List<QuestionVo> findQuestoinDetailCondition(Integer currentPage, Integer size, String key) {
        return questionDao.findQuestoinDetailCondition(currentPage, size, key);
    }

    @Override
    public List<QuestionVo> findAll() {
        return questionDao.findAll();
    }

    @Override
    public List<QuestionTopVo> findQuestionTop() {
        return questionDao.findQuestionTop();
    }

    @Override
    public QuestionVo findQuestionDetailById(Integer id) {
        return questionDao.findQuestionDetailById(id);
    }

    @Override
    public List<QuestionVo> findQuestionByType(Integer currentPage, Integer size, Integer typeId) {
        return questionDao.findQuestionByType(currentPage, size, typeId);
    }

    @Override
    public Integer findQuestionByTypeCount( Integer typeId) {
        return questionDao.findQuestionByTypeCount(typeId);
    }

    @Override
    public List<QuestionVo> findQuestionByTag(Integer currentPage, Integer size, Integer tagId) {
        return questionDao.findQuestionByTag(currentPage, size, tagId);
    }

    @Override
    public Integer findQuestionByTagCount(Integer tagId) {
        return questionDao.findQuestionByTagCount(tagId);
    }

    @Override
    public List<ArchiveQuestionVo> findArchiveQuestionList(Integer currentPage, Integer size) {
        return questionDao.findArchiveQuestionList(currentPage, size);
    }


}
